<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="js/jquery-3.5.1.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div>商品编号<span id="itemId"></span></div>
    <div>商品价格<span id="itemPrice"></span></div>
    <Script>
        // jquery提供ajax，参数是一个js对象{}
        $.ajax({
            type: "GET",
            url: "https://p.3.cn/prices/mgets?skuIds=J_100005185603",
            contentType: "application/json;charset=utf-8",
            dataType: "jsonp",
            success: function (data) {
                console.log("访问成功")
                console.log(data)
                // 解析id和price
                var item = data[0];//获取这条记录
                var itemId = item.id;
                var itemPrice = item.p;
                console.log(itemId);
                console.log(itemPrice);
                var id = $("#itemId");
                id.text(itemId);
                id.css("color", "blue");
                var price = $("#itemPrice");
                price.text(itemPrice);
                price.css("color", "red");
            }, eror: function (e) {
                console.log("访问失败")
            }
        })
        // $.ajax({
        //     type: "POST",
        //     url: "https://p.3.cn/prices/mgets",
        //     data: {
        //         "skuIds": "J_100005185603"
        //     },
        //     contentType: "application/json;charset=utf-8",
        //     dataType: "jsonp",
        //     success: function (data) {
        //         console.log("访问成功")
        //         console.log(data)
        //         // 解析id和price
        //         var item = data[0];//获取这条记录
        //         var itemId = item.id;
        //         var itemPrice = item.p;
        //         console.log(itemId);
        //         console.log(itemPrice);
        //         var id = $("#itemId");
        //         id.text(itemId);
        //         id.css("color", "blue");
        //         var price = $("#itemPrice");
        //         price.text(itemPrice);
        //         price.css("color", "red");
        //     }, eror: function (e) {
        //         console.log("访问失败")
        //     }
        // })
    </Script>
</body>

</html>